package com.Rendering.StageScene;


import com.Gameplay.character.Role.parentRole;
import com.Rendering.UI.HUD.HUD;
import javafx.scene.*;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.effect.Light;
import javafx.scene.effect.Lighting;
import javafx.scene.image.Image;

import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import org.fxyz3d.scene.Skybox;


public class GameScene {
    private Scene scene;
    private Pane Layout;
    private GraphicsContext entityRenderGC;
    private HUD hud;
    /*
    private final Scene scene;
    //player render 及人物渲染层
    private final Canvas entityRenderCanvas = new Canvas(2880, 900);
    private final GraphicsContext entityRenderGC = entityRenderCanvas.getGraphicsContext2D();
    //draw 绘制 即UI 等绘制
    private final Canvas drawerCanvas = new Canvas(2880, 900);
    //Hud布局
    private Group HudGroup;
    private final HUD hud;

    private final Pane Layout;
    //为场景添加影响
    private Lighting lighting;


    public GameScene() {
        Layout = new AnchorPane();

        Skybox skybox = getSkybox();
        lighting = new Lighting();
        Light.Point point = new Light.Point();
        point.setColor(Color.WHITE);
        point.setX(2000);
        point.setZ(2000);
        lighting.setLight(point);

        hud = new HUD(drawerCanvas);
        HudGroup = new Group();
        HudGroup.getChildren().add(0, drawerCanvas);
        HudGroup.getChildren().add(1, hud.getTime());


        skybox.getChildren().get(4).setEffect(lighting);

        Layout.getChildren().add(0, skybox);
        entityRenderCanvas.setDepthTest(DepthTest.DISABLE);
        Layout.getChildren().add(1, entityRenderCanvas);
        Layout.getChildren().addAll(HudGroup);
        scene = new Scene(Layout, 2880, 900, false, SceneAntialiasing.DISABLED);
        scene.setCamera(new PerspectiveCamera());
    }

    private static Skybox getSkybox() {
        Image[] image = new Image[]{
                //top bottom
                new Image("BackGround/back.png"),
                //left right
                new Image("BackGround/frontBack.png"),
                //front back
                new Image("BackGround/frontBack.png"),new Image("BackGround/back.png"),
        };

        PerspectiveCamera camera = new PerspectiveCamera();

        Skybox skybox = new Skybox(image[0], image[0], image[1], image[1], image[2], image[3], 2880, camera);
        skybox.setTranslateY(-850);
        skybox.setTranslateZ(-30);
        return skybox;
    }


     */
    public Scene getScene() {
        return scene;
    }

    //获取布局
    public Pane getLayout() {
        return Layout;
    }

    public GraphicsContext getEntityRenderGC() {
        return entityRenderGC;
    }

    public void drawHUD(parentRole P1, parentRole P2) {
        hud.draw(P1, P2);


    }


}
